import cv2 as cv

cap = cv.VideoCapture(0)
while True:
   isReadOk, frame =cap.read()
   frame = cv.flip(frame, 1)
   frame = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
   cv.imshow('camera', frame)
   if cv.waitKey(50) != -1:
      break
cap.release()
cv.destroyAllWindows()